package com.holly.unit.mongodb.service.impl;

import com.holly.unit.mongodb.api.MongodbApi;
import com.holly.unit.mongodb.entity.HollyMapEntity;
import com.holly.unit.mongodb.mapper.HollyMapRepository;
import com.holly.unit.mongodb.service.HollyMapService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * Mongodb 数据存储实现类
 *
 * @author holly
 * @date 2021/03/20 16:24
 */
@Service
public class HollyMapServiceImpl implements HollyMapService, MongodbApi<HollyMapEntity, String> {

    @Resource
    private HollyMapRepository hollyMapRepository;

    @Override
    public HollyMapEntity insert(HollyMapEntity hollyMapEntity) {
        return hollyMapRepository.insert(hollyMapEntity);
    }

    @Override
    public HollyMapEntity update(HollyMapEntity hollyMapEntity) {
        return hollyMapRepository.save(hollyMapEntity);
    }

    @Override
    public void deleteById(String id) {
        hollyMapRepository.deleteById(id);
    }

    @Override
    public Optional<HollyMapEntity> findById(String id) {
        return hollyMapRepository.findById(id);
    }

    @Override
    public List<HollyMapEntity> findAll() {
        return hollyMapRepository.findAll();
    }

}
